package com.hmy.infrastructure.common.properties;

import com.hmy.infrastructure.common.enums.VerificationCodeType;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 短信配置
 *
 * @author xiongwei
 * @description: TODO
 * @date 2023/11/13
 */
@Data
@Validated
@Component
@ConfigurationProperties(prefix = SmsProperties.PREFIX)
public class SmsProperties {

    public static final String PREFIX = "aliyun.sms";

    @NotBlank
    private String regionId;

    @NotBlank
    private String accessKeyId;

    @NotBlank
    private String accessKeySecret;

    /**
     * 默认签名名称
     */
    @NotBlank
    private String defaultSignName;
    private List<String> defaultCodePhoneList;

    /**
     * 验证码配置
     */
    @NotNull
    private List<VerificationCode> codeList;

    @Data
    public static class VerificationCode {
        /**
         * 业务编码
         */
        private String businessKey;
        /**
         * 短信模板
         */
        private String templateCode;
        /**
         * 验证码类型
         */
        @NotNull
        private VerificationCodeType type;

        /**
         * 验证码长度
         */
        @NotNull
        private Integer length;
        /**
         * 有效时长，秒
         */
        @NotNull
        private Long validTime;

        /**
         * 模板参数key
         */
        @NotNull
        private String codeKey;
    }
}

